package com.jinlia.show.modules.base.config;

import com.jinlia.show.common.core.utils.CacheUtils;
import com.jinlia.show.modules.base.config.bean.MybatisBaseTypeHandler;
import com.jinlia.show.modules.base.system.service.AreaCodeMapperService;
import com.jinlia.show.modules.base.utils.AdminCodeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

/**
 * 为工具类注入spring对象
 */
@Component
public class CommandBeanConfig implements CommandLineRunner {
    @Autowired
    JdbcTemplate jdbcTemplate;

    @Value("${file.uri}")
    String fileUrl;
    @Value("${file.local-uri}")
    String fileLocalUrl;
    @Autowired
    AreaCodeMapperService areaCodeMapperService;

    @Override
    public void run(String... args) {
        CacheUtils.newInstance(jdbcTemplate);
        AdminCodeUtils.newInstance(areaCodeMapperService);
        MybatisBaseTypeHandler.fileUrl = fileLocalUrl;
    }
}
